<!DOCTYPE html>
<html>
<head>
<#include "/common/common.ftl" parse=true encoding="utf-8">
<style>
.email-logo {
	margin-bottom: 30px;
	text-align: center;
}

h2 {
	text-align: center;
	margin-right: auto;
	margin-left: auto;
	width: 80%;
	padding-bottom: 25px;
	border-bottom: 1px solid #CCC;
}

.step {
	position: relative;
	text-align: center;
	margin-right: auto;
	margin-left: auto;
	margin-top: 20px;
	margin-bottom: 20px;
	width: 80%;
}

.step2 {
	left: 260px;
	position: absolute;
	top: 1px;
	width: 30px;
}

.step3 {
	left: 459px;
	width: 30px;
	position: absolute;
	top: 1px;
}

.step3 {
	left: 459px;
	width: 30px;
	position: absolute;
	top: 1px;
}

.form-control2, .submit {
	height: 44px;
}
</style>
</head>
<body>
	<#include "/common/header.ftl" parse=true encoding="utf-8">


	<div class="container body_content">
		<div class="row">
			<h2>找回密码</h2>
			<div class="step" style="width: 550px">
				<img class="step2" src="${base}/styles/images/common/step2.png"> <img class="step3" src="${base}/styles/images/common/step3.png"> <img height="60px;" src="${base}/styles/images/common/step.png">
			</div>
			<div class="col-md-10">
				<form class="form-horizontal" id="defaultForm" method="post">
					<input type="hidden" id="id" name="id" value="${entity.id!}">
					<input type="hidden" id="secretKey" name="secretKey" value="${secretKey!}">
					<div class="form-group">
						<div class="col-md-offset-5 col-md-5">
							<input class="form-control form-control2 text_color inputItem" id="password" type="password" name="password" placeholder="新密码" />
						</div>
					</div>
					<div class="form-group">
						<div class="col-md-offset-5 col-md-5">
							<input class="form-control form-control2 text_color inputItem" id="confirmPassword" type="password" name="confirmPassword" placeholder="确认密码" />
						</div>
					</div>
					<div class="form-group">
						<div class="col-md-offset-5 col-md-5">
							<button style="width: 100%;" type="submit" class="btn btn-primary btn-block btn-flat submit">提交</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<#include "/common/footer.ftl" parse=true encoding="utf-8">
	<script src="${base}/scripts/js/md5.js"></script>
	<script type="text/javascript">
	$('#defaultForm').bootstrapValidator({
	    message: '该项不能为空',
	    live: 'disabled',
	    feedbackIcons: {
	        valid: 'glyphicon glyphicon-ok',
	        invalid: 'glyphicon glyphicon-remove',
	        validating: 'glyphicon glyphicon-refresh'
	    },
	    submitHandler: function(validator, form, submitButton) {
	        bootbox.setLocale("zh_CN");
	        if (window.confirm("确定修改该用户的密码吗？")) {
	        	var url = "${base}/retrievePassword/step2Action.json";
	            var entity = {
	                id: $("#id").val(),
	                secretKey: $("#secretKey").val(),
	                password: md5($("#password").val())
	            };
	            var onloadFunc = function(result) {
	                if (result.isSuccess == true) {
	                    window.location = "${base}/retrievePassword/success.html";
	                } else {
	                	window.location = "${base}/retrievePassword/failure.html";
	                }
	            };
	            httpRequestPostSubmitJson(form, url, entity, false, onloadFunc);
	        }
	    },
		fields : {
			password : {
				validators : {
					notEmpty : {
						message : '密码不能为空'
					},
					identical: {
                        field: 'confirmPassword',
                        message: '密码与确认密码输入不一致'
                    },
                    stringLength: {
                        min: 6,
                        max: 12,
                        message: '密码长度在6-12个字符之间'
                    }
				}
			},
			confirmPassword : {
				validators : {
					notEmpty : {
						message : '确认密码不能为空'
					},
					identical: {
                        field: 'password',
                        message: '密码与确认密码输入不一致'
                    },
                    stringLength: {
                        min: 6,
                        max: 12,
                        message: '密码长度在6-12个字符之间'
                    }
				}
			}
		} 
	});
	</script>
</body>
</html>